﻿using AutoMapper;
using DDDNorthWind.Core.Domain.ValueObject;

namespace DDDNorthWind.AC.ImportProducts.Domain.ValueObjects
{
    public class ImportProductWeight : ValueObject<ImportProductWeight>
    {
        static ImportProductWeight()
        {
            Mapper.CreateMap<ImportProductWeight, ImportProductWeight>();
        }

        public ImportProductWeight()
        {
            
        }

        public ImportProductWeight(double weight, ImportUnitOfWeight weightIn )
        {
            Weight = weight;
            WeightIn = weightIn;
        }

        public double Weight { get; private set; }

        public ImportUnitOfWeight WeightIn { get; private set; }

        #region "Equals"
        public override bool Equals(object obj)
        {
            return base.Equals(obj);
        }

        public override bool Equals(ImportProductWeight other)
        {
            if (ReferenceEquals(null, other)) return false;
            if (ReferenceEquals(this, other)) return true;
            return other.Weight.Equals(Weight) 
                && Equals(other.WeightIn, WeightIn);
        }

        public override int GetHashCode()
        {
            unchecked
            {
                return (Weight.GetHashCode() * 397) ^ WeightIn.GetHashCode();
            }
        }

        public static bool operator ==(ImportProductWeight left, ImportProductWeight right)
        {
            return Equals(left, right);
        }

        public static bool operator !=(ImportProductWeight left, ImportProductWeight right)
        {
            return !Equals(left, right);
        } 
        #endregion
    }
}